import eslint from '@eslint/js';
import tsEslint from 'typescript-eslint';
import eslintPluginVue from 'eslint-plugin-vue';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import unusedImports from 'eslint-plugin-unused-imports';
import globals from 'globals';

export default tsEslint.config(
  /** js推荐配置 */
  eslint.configs.recommended,
  /** ts推荐配置 */
  tsEslint.configs.strict,
  tsEslint.configs.stylistic,
  /** vue推荐配置 */
  eslintPluginVue.configs['flat/recommended'],
  eslintPluginPrettierRecommended,
  {
    ignores: [
      '**/node_modules',
      'lerna.json',
      'package.json',
      'tsconfig.json',
      'pnpm-lock.yaml',
      'pnpm-workspace.yaml',
      'rollup.config.js',
      'eslint.config.mjs',
      '**/out',
    ],
    files: ['**/*.ts'],
    plugins: {
      'unused-imports': unusedImports,
    },
    languageOptions: {
      globals: {
        ...globals.browser,
      },
      ecmaVersion: 'latest',
      sourceType: 'module',
    },
    rules: {
      'no-console': 'off',
      'no-debugger': 'off',
      'no-undef': [0],
      'no-plusplus': [
        'error',
        {
          allowForLoopAfterthoughts: true,
        },
      ],
      'class-methods-use-this': [0],
      'prefer-destructuring': [0],
      'import/no-unresolved': [0],
      'unused-imports/no-unused-imports': 'error',
      'no-underscore-dangle': [0],
      'no-restricted-syntax': [0],
      'no-continue': [0],
      'consistent-return': [0],
      'func-names': [0],
      'import/extensions': [0],
      'import/prefer-default-export': [0],
      'vue/no-setup-props-destructure': [0],
      'vue/require-default-prop': [0],
      'no-unused-vars': 'off',
      '@typescript-eslint/no-unused-vars': [
        'error',
        {
          argsIgnorePattern: '^_',
        },
      ],
      '@typescript-eslint/no-inferrable-types': [0],
      '@typescript-eslint/no-explicit-any': ['error'],
      '@typescript-eslint/explicit-module-boundary-types': 'error',
      '@typescript-eslint/no-non-null-assertion': [0],
      '@typescript-eslint/no-extraneous-class': [0],
      'no-extraneous-class': [0],
      'no-param-reassign': [0],
      'no-useless-constructor': [0],
      'no-empty-function': [0],
    },
  },
);
